package com.ruoyi.passengers.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.passengers.domain.MileageInformation;
import com.ruoyi.passengers.service.IMileageInformationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 里程信息Controller
 * 
 * @author ruoyi
 * @date 2025-08-17
 */
@RestController
@RequestMapping("/mileageInfo")
public class MileageInformationController extends BaseController
{
    @Autowired
    private IMileageInformationService mileageInformationService;

    /**
     * 查询里程信息列表
     */
    @RequiresPermissions("passengers:mileageInfo:list")
    @GetMapping("/list")
    public TableDataInfo list(MileageInformation mileageInformation)
    {
        startPage();
        List<MileageInformation> list = mileageInformationService.selectMileageInformationList(mileageInformation);
        return getDataTable(list);
    }

    /**
     * 导出里程信息列表
     */
    @RequiresPermissions("passengers:mileageInfo:export")
    @Log(title = "里程信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MileageInformation mileageInformation)
    {
        List<MileageInformation> list = mileageInformationService.selectMileageInformationList(mileageInformation);
        ExcelUtil<MileageInformation> util = new ExcelUtil<MileageInformation>(MileageInformation.class);
        util.exportExcel(response, list, "里程信息数据");
    }

    /**
     * 获取里程信息详细信息
     */
    @RequiresPermissions("passengers:mileageInfo:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mileageInformationService.selectMileageInformationById(id));
    }

    /**
     * 新增里程信息
     */
    @RequiresPermissions("passengers:mileageInfo:add")
    @Log(title = "里程信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MileageInformation mileageInformation)
    {
        return toAjax(mileageInformationService.insertMileageInformation(mileageInformation));
    }

    /**
     * 修改里程信息
     */
    @RequiresPermissions("passengers:mileageInfo:edit")
    @Log(title = "里程信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MileageInformation mileageInformation)
    {
        return toAjax(mileageInformationService.updateMileageInformation(mileageInformation));
    }

    /**
     * 删除里程信息
     */
    @RequiresPermissions("passengers:mileageInfo:remove")
    @Log(title = "里程信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mileageInformationService.deleteMileageInformationByIds(ids));
    }
}
